<?php
/**
 * Created by PhpStorm.
 * User: sosyuki
 * Date: 2018-12-07
 * Time: 15:02
 */

namespace Drupal\points\MetadataController;


use EntityDefaultMetadataController;

class PointsMetadataController extends EntityDefaultMetadataController {

  public function entityPropertyInfo() {
    $info = parent::entityPropertyInfo();
    $properties = &$info[$this->type]['properties'];

    $properties['label'] = [
      'label' => t('Label'),
      'description' => t('The profile label.'),
      'setter callback' => 'entity_property_verbatim_set',
      'setter permission' => 'administer profiles',
      'schema field' => 'label',
    ];

    $properties['type'] = [
        'type' => 'points_type',
        'setter permission' => 'administer profiles',
        'required' => TRUE,
        'description' => t('The profile type.'),
      ] + $properties['type'];

    unset($properties['uid']);

    $properties['user'] = [
      'label' => t("User"),
      'type' => 'user',
      'description' => t("The owner of the profile."),
      'setter callback' => 'entity_property_verbatim_set',
      'setter permission' => 'administer profiles',
      'required' => TRUE,
      'schema field' => 'uid',
    ];
    $properties['op_user'] = [
      'label' => 'x操作人',
      'type' => 'user',
      'schema field' => 'op_uid',
      'description' => t('操作人.'),
    ];
    $properties['description'] = [
      'label' => t("描述"),
      'type' => 'text',
      'description' => t("The owner of the profile."),
      'setter callback' => 'entity_property_verbatim_set',
      'setter permission' => 'administer profiles',
      'required' => TRUE,
      'schema field' => 'description',
    ];

    $properties['created'] = [
      'label' => t("Date created"),
      'type' => 'date',
      'description' => t("The date the profile was created."),
      'setter permission' => 'administer profiles',
      'schema field' => 'created',
    ];
    $properties['changed'] = [
      'label' => t("Date changed"),
      'type' => 'date',
      'schema field' => 'updated',
      'description' => t("The date the profile was most recently updated."),
    ];

    $properties['only_update'] = [
      'label' => t("仅仅更新"),
      'type' => 'boolean',
      'description' => t("仅仅更新."),
      'setter callback' => 'entity_property_setter_method',
      'setter permission' => 'administer points',
    ];

    return $info;
  }
}
